<template>
  <div class="right_top">
    <ul class="list">
      <li class="item" :class="{'active': active}" v-for="(item, index) of list" :key="index">
        <img :src="item.img" alt="">
        <p>{{item.news}}</p>
        <span>{{item.time}}</span>
      </li>
    </ul>
  </div>
</template>

<script>
import {getResumeNews} from "../api";

export default {
  name: 'RightTop',
  data () {
    return {
      list: [],
      active: true
    }
  },
  methods: {
    init () {
      setInterval(() => {
        getResumeNews().then(res => {
          this.active = false
          this.list = res.data.data.resume_news
        })
      }, 3000)
    }
  },
  mounted () {
    this.init()
  }
}
</script>

<style lang="scss" scoped>
@import "src/assets/scss/var_";

.right_top {
  color: #ffffff;
  height: $top_height;
  overflow: hidden;

  .list {
    padding: 10px;
    max-height: $top_height - $_10px * 1.5;
    overflow: hidden;

    .item {
      height: $fontSize_18;
      line-height: $fontSize_18;
      font-size: $fontSize_12;
      display: flex;
      justify-content: space-between;
      align-items: center;
      transition: .5s linear;
      opacity: 1;

      &.active {
        opacity: 0;
      }

      /*animation: ani_loop 5s infinite;*/
      img {
        height: $fontSize_10;
      }

      p {
        width: 30%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
  }
}
</style>
